﻿// -----------------------------------------------------------------------
// <copyright file="TestInfrastructure.cs" company="EPAM Systems">
////Copyright (c) EPAM Systems, 2012. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

namespace MBOP.Tests.TestsInfrastructure
{
	#region Usings

	using System.Web;

	using Moq;

	#endregion

	/// <summary>
	/// Provides infrastructure to unit tests
	/// </summary>
	public static class TestInfrastructure
	{
		#region Static Methods

		/// <summary>
		/// Gets imitation of the http context.
		/// </summary>
		/// <param name="inputUrl">The requested url.</param>
		/// <param name="httpMethod">The http request method.</param>
		/// <returns>The Http context base.</returns>
		public static HttpContextBase GetHttpContext(string inputUrl, string httpMethod)
		{	
			Mock<HttpRequestBase> mockRequest = new Mock<HttpRequestBase>();

			mockRequest.Setup(request => request.AppRelativeCurrentExecutionFilePath).Returns(inputUrl);
			mockRequest.Setup(request => request.HttpMethod).Returns(httpMethod);

			Mock<HttpResponseBase> mockResponse = new Mock<HttpResponseBase>();

			mockResponse.Setup(response => response.ApplyAppPathModifier(It.IsAny<string>())).Returns<string>(path => path);

			Mock<HttpContextBase> mockHttpContext = new Mock<HttpContextBase>();

			mockHttpContext.Setup(context => context.Request).Returns(mockRequest.Object);
			mockHttpContext.Setup(context => context.Response).Returns(mockResponse.Object);

			return mockHttpContext.Object;
		}

		#endregion
	}
}
